<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
  <h3>详情页 -- <span id="title"></span> </h3>

  <script>
/*     let title = document.getElementById('title')

    window.onmessage = function (e) { // 接受父级页面发送的消息
      console.log(e.data);
      console.log(1111);
      
      title.innerHTML = e.data.age
      console.log(e.data.age);
      
      e.source.postMessage('阿杰 20了') 
    } */
    window.onmessage = function(e){
        console.log(e.data.name);
        e.source.postMessage('阿杰 20了')
    }
  </script>
</body>
</html>
<!--  e.source: 对发送消息的 window 对象的引用。这使得接收方可以直接回复给发送方。 -->